[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
CONTINUE
The continue statement is used within a loop (while, do...while, or
for statement). The continue statement has the form:
continue;
It is illegal for a continue statement to appear outside of a loop
body. When a continue statement is encountered, program control is
immediately transferred to the end of the body of the innermost en-
closing while, do...while, or for statement. The effect in a while
or do...while statement is that the condition part of the while or
do...while statement is evaluated, and the next iteration of the
loop occurs. For example:
num = 0;
while (num < 100000)
{
num = num + 1;
if (num > 100)
continue;
prints("Hello");
}
The effect of the continue statement in the above loop would be that
'Hello' would only be printed while 'num' was smaller or equal to
100, as the continue statement is executed when num is bigger than
100, which causes the rest of the loop body to be skipped. An ex-
ample for statement would be:
for (num = 0; num < 100000; num = num + 1)
{
if (num > 100)
continue;
prints("Hello");
}
The effect in this case would be the same. While 'num' is smaller or
equal to 100, the entire loop body executes. If 'num' is greater
than 100 however, the continue statement is executed. This causes
the rest of the loop body to be skipped, so the 'Hello' is then not
printed.
See Also:
break
do
for
while
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson